<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="button">button</button>
    <!-- 列表 -->
    <ul id="container"></ul>
    <script>
        document.getElementById('button').addEventListener('click', function(){
            let now = new Date();
            // 插入一万条
            const total = 10000;
            let ul = document.getElementById('container');
            const oFragment = document.createDocumentFragment(); // 早期性能优化
            for (let i = 0; i < total; i++) {
                let li = document.createElement('li');
                li.innerText = Math.ceil(Math.random() * total)
                ul.appendChild(li);
                // oFragment.appendChild(li); // 在内存中挂载
            };
            // ul.appendChild(oFragment);
            console.log('JS运行时间:', Date.now() - now)
            // setTimeout(() => {
            //     console.log("总运行时间为", )
            // }, )
        })
    </script>
</body>
</html>